﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
using Microsoft.Services.TestTools.UITesting.Html;

namespace TestBing
{
    public enum ControlTypes
    {
        HtmlHyperlink,
        HtmlButton,
        HtmlCheckBox,
        HtmlDiv,
        HtmlTable,
        HtmlEdit,
        HtmlComboBox,
        HtmlImage,
        HtmlTextArea,
        HtmlCell,
        HtmlInputButton,
        HtmlRadioButton,
        HtmlCustom
    }

    public class Controls
    {
        public static object GetControl(BrowserWindow Browser, ControlTypes controlType, object findCriterias)
        {
            switch (controlType)
            {
                case ControlTypes.HtmlHyperlink:
                    return Browser.Find<HtmlHyperlink>(findCriterias);

                case ControlTypes.HtmlButton:
                    return Browser.Find<HtmlButton>(findCriterias);

                case ControlTypes.HtmlCheckBox:
                    return Browser.Find<HtmlCheckBox>(findCriterias);

                case ControlTypes.HtmlDiv:
                    return Browser.Find<HtmlDiv>(findCriterias);

                case ControlTypes.HtmlEdit:
                    return Browser.Find<HtmlEdit>(findCriterias);

                case ControlTypes.HtmlComboBox:
                    return Browser.Find<HtmlComboBox>(findCriterias);

                case ControlTypes.HtmlCell:
                    return Browser.Find<HtmlCell>(findCriterias);

                case ControlTypes.HtmlTextArea:
                    return Browser.Find<HtmlTextArea>(findCriterias);

                case ControlTypes.HtmlImage:
                    return Browser.Find<HtmlImage>(findCriterias);

                case ControlTypes.HtmlInputButton:
                    return Browser.Find<HtmlInputButton>(findCriterias);

                case ControlTypes.HtmlTable:
                    return Browser.Find<HtmlTable>(findCriterias);

                case ControlTypes.HtmlRadioButton:
                    return Browser.Find<HtmlRadioButton>(findCriterias);

                case ControlTypes.HtmlCustom:
                    return Browser.Find<HtmlCustom>(findCriterias);

                default:
                    return Browser.Find<HtmlHyperlink>(findCriterias);

            }
        }
    }
}
